/**
 * @Author:Geln Yang
 * @Created:2008-8-3
 * $ Revision: 1.0 $
 * $ Author: Geln Yang $
 * $ Date: 2008-8-3 $
 */
package org.geln.web.webwork.interceptor;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * @Author:Geln Yang
 * @Created:2008-8-3
 */
public class ExceptionHolder {
    private Exception exception;
    private String message;

    public ExceptionHolder(String message,Exception exception) {
        this.exception = exception;
        this.message = message;
    }

    public Exception getException() {
        return this.exception;
    }

    public String getMessage() {
		return message;
	}

	public String getExceptionStack() throws IOException {
        String exceptionStack = null;

        if (getException() != null) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);

            try {
                getException().printStackTrace(pw);
                exceptionStack = sw.toString();
            }
            finally {
                sw.close();
                pw.close();
            }
        }

        return exceptionStack;
    }

}
